package Controller;

import Util.Page;
import entity.Emp;
import service.EmpService;
import service.impl.EmpServiceimpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/*
 *徐韬
 *2021/9/21
 *12:48
 */
@WebServlet("/ShowAllController")
public class ShowAllEmpController extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String pageIndex = request.getParameter("pageIndex");
        System.out.println(pageIndex);
        if(pageIndex ==null){
            pageIndex ="1";
        }
        Page page = new Page(Integer.valueOf(pageIndex));



        EmpService empService = new EmpServiceimpl();

        List<Emp> empList = empService.showAllEmp(page);
        request.setAttribute("empList", empList);
        request.setAttribute("page", page);
        request.getRequestDispatcher("/emplist.jsp").forward(request,response);



    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    doPost(request,response);
    }
}
